import java.util.Arrays;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author OnCloud9
 * @description
 * @project Java
 * @date 2022年05月22日 10:09
 */
public class StreamToMap {

    public static void main(String[] args) {

        String[] arr = {"a", "c", "a", "b", "d", "c"};
        System.out.println(Arrays.toString(arr));
        Stream
        .of(arr)
        .collect(Collectors.toMap(k -> k, k -> 1, Integer::sum))
//        .collect(Collectors.toMap(k -> k, k -> 1, Integer::sum))
        .forEach((k, v) -> System.out.println(k + " : " + v));


    }
}
